[SQL]Summing a column while ignoring duplicate records(row_number())


SELECT custid, SUM(amount)
FROM (SELECT t.*,
             ROW_NUMBER() OVER (PARTITION BY custid, transid ORDER BY transid) AS seqnum
      FROM table_1 t
     ) t
WHERE seqnum = 1;
#SQL






你可能感興趣的文章

[Release Notes] 20210317_v1 - Support Insert img path and save button in post editor

[Release Notes] 20210317_v1 - Support Insert img path and save button in post editor

a tag 遺失 block 屬性

a tag 遺失 block 屬性

金魚系列,盒模型篇

金魚系列,盒模型篇






留言討論